package View;

import client.ClientManager;
import instruction.Group;
import instruction.User;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.StageStyle;

import java.io.IOException;

public class AddGroupWindow extends window {
    private Group group;
    public Group getGroup() {
        return group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    public AddGroupWindow() throws IOException {
        root = FXMLLoader.load(getClass().getResource("/Fxml/searchGroup.fxml"));
        Scene scene = new Scene(root, 400, 400);
        scene.setFill(Color.TRANSPARENT);
        setScene(scene);
        initStyle(StageStyle.TRANSPARENT);
        setResizable(false);
        setTitle("We Chat");
        Image image=new Image("/Picture/sourceMaterial/查询群背景图.jpg",612,400,false,false);
        ((ImageView)$("backgroundImage")).setImage(image);
        move();
        quit();
        setIcon();
        minimiser();
    }

    //退出
    @Override
    public void quit() {
        ((Button) $("exitButton")).setTooltip(new Tooltip("退出"));
        ((Button) $("exitButton")).setOnAction(event -> {
            close();
        });

    }
    //最小化
    @Override
    public void minimiser() {
        ((Button) $("ministerButton")).setTooltip(new Tooltip("最小化"));
        ((Button) $("ministerButton")).setOnAction(event -> {
            setIconified(true);
        });
    }
    public void setGroupData(){
        Circle circle = new Circle();
        circle.setRadius(40);
        circle.setCenterX(40);
        circle.setCenterY(40);
        ((ImageView)$("groupImage")).setImage(new Image(group.getImage(),80,80,false,false));
        ((ImageView)$("groupImage")).setClip(circle);
        ((Label)$("groupAccount")).setText(group.getAccount());
        ((Label)$("groupIntroduction")).setText(group.getIntroduction());
        ((Label)$("groupName")).setText(group.getName());

    }

}
